class_name WhiteFadeEffect
extends Control

@export var fade_time: float = 3.0
@onready var color_rect: ColorRect = $ColorRect


func fade_in(callback: Callable = Callable()):
	var tween_alpha = create_tween()
	tween_alpha.tween_property(color_rect, "modulate:a", 1.0, fade_time) \
	.set_trans(Tween.TRANS_CUBIC) \
	.set_ease(Tween.EASE_IN_OUT).from_current()
	
	if callback.is_valid():
		tween_alpha.tween_callback(callback)
	
	
func fade_out(callback: Callable = Callable()):
	var tween_alpha = create_tween()
	tween_alpha.tween_property(color_rect, "modulate:a", 0.0, fade_time) \
	.set_trans(Tween.TRANS_CUBIC) \
	.set_ease(Tween.EASE_IN_OUT)
	
	if callback.is_valid():
		tween_alpha.tween_callback(callback)
